﻿Public Class Test_SwitchInfoReadr
    Private WithEvents InfoRdr As New PurpleKnife.Library.SwitchInfoReader
    Private SwInf As PurpleKnife.Library.pkSwitchInfo

    Private Sub Test_SwitchInfoReadr_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub InfoRdr_ReadCompleted(sender As Object, e As PurpleKnife.Library.SwitchInfoReader.ReadCompletedEventArgs) Handles InfoRdr.ReadCompleted
        SwInf = e.SwitchInformation
        If InvokeRequired Then
            Invoke(New MethodInvoker(AddressOf UpdateUI))
        Else
            UpdateUI()
        End If
    End Sub

    Private Sub UpdateUI()
        txtSysName.Text = SwInf.SysName
        txtSysLocation.Text = SwInf.SysLocation
        txtSysContact.Text = SwInf.SysContact
        txtSystemMAC.Text = SwInf.SystemMAC
        txtSystemType.Text = SwInf.SystemType
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim Switch As New PurpleKnife.Library.pkSwitch
        Switch.SSHHost = "172.16.1.0"
        Switch.SSHPort = 22
        Switch.SSHUserName = "admin"
        Switch.SSHPassword = "password"
        Switch.SSHConnectionTimeout = TimeSpan.FromSeconds(8)
        InfoRdr.Read(Switch)
    End Sub
End Class